<?php
require_once("report.php");
class Variance extends Report
{
	function __construct()
	{
		parent::__construct();
	}
	
    public function getDataColumns()
	{
		return array();
	}
    
	public function getData(array $inputs)
	{  		
	    $this->db->select('id, analysis_time, employee_id', false);
		$this->db->from('cash_analysis');
		$this->db->where('analysis_time BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and employee_id='.$inputs['employee_id']);
		$this->db->order_by('analysis_time DESC');
        $cash_analysis_data = $this->db->get();
        
        if(!$cash_analysis_data){
            return false;
        }
        
        $all_data = array();
        foreach($cash_analysis_data->result_array() as $row){
            $row_data = array();
            
            $id = $row['id'];
            $analysis_time = $row['analysis_time'];
            $employee_id = $row['employee_id'];
            
            $this->db->select('item_id, item_quantity, item_unitprice, sales_quantity, returns_quantity, time_quantity', false);
    		$this->db->from('cash_analysis_details');
    		$this->db->where('cash_analysis_details.cash_analysis_id',$id);
    		$cash_analysis_details_data = $this->db->get();
            
            $row_data['date'] = $analysis_time;
            $row_data['employee_id'] = $employee_id;
            $row_data['data'] = ($cash_analysis_details_data) ? $cash_analysis_details_data->result_array() : false;
        
            $all_data[] = $row_data;
        }
        
		return $all_data;
	}
    
    public function getSummaryData(array $inputs)
	{
		return array();
	}
}
?>